package com.heima.feigns;

import com.heima.config.FeignConfig;
import com.heima.feigns.fallback.ArticleFallBack;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.vos.SearchArticleVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(
        value = "leadnews-article",
        fallbackFactory = ArticleFallBack.class,
        configuration = FeignConfig.class
)
public interface ArticleFeign {

    @GetMapping("/api/v1/author/findByUserId/{id}")
    ResponseResult findAuthorByUserId(@PathVariable("id") Integer id);


    @PostMapping("/api/v1/author/save")
    ResponseResult addAuthor(@RequestBody ApAuthor apAuthor);

    @PostMapping("/api/v1/article/save")
    ResponseResult addArticle(ArticleDto articleDto);

    @GetMapping("/api/v1/article/{id}")
    ResponseResult<SearchArticleVo> findArticle(@PathVariable("id") Long id);
}
